import { useEffect, useState } from 'react'
// import { useParams } from 'react-router-dom'
import { Datum, fetchSupportCateAPI } from '@/apis/support'
// import { log } from 'console'

function useSupport() {
  // 标题
//   const [headers, setHeaders] = useState<HeaderItem["caption"]>()
  // 图片
  const [imgs, setImgs] = useState<Datum[]>([])
  // const params = useParams()
  // const id = params.id
  // console.log(id);
  
  useEffect(() => {
    const getSupportCate = async () => {
      try {
        const res = await fetchSupportCateAPI()
        // console.log(res);
        // setHeaders(res.data.head[0].caption)
        setImgs(res.data.data)
      } catch (error) {
        throw new Error('fetch ProductAll error')
      }
    }
    getSupportCate()
  }, [])
  // 暴露数据
  return {
    imgs
  }
}

export { useSupport }
